import type { Temp } from '../types/temp'

export { disposeAll }

/** 统一调用Three.js的dispose函数 */
function disposeAll(x: Temp.DisposableType) {
  if (x.geometry) x.geometry.dispose()
  if (x.material) {
    Array.isArray(x.material) ? x.material.forEach((m) => m.dispose()) : x.material.dispose()
  }
  if (x.children) x.children.forEach(disposeAll)
}
